package com.hn658.user.core.dao.db.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.hn658.framework.dataaccess.mybatis.AbstractMyBatisDAO;
import com.hn658.user.common.entity.AppInfoEO;
import com.hn658.user.core.dao.db.IUserAppDBDAO;

@Repository
public class UserAppDBDAOImpl extends AbstractMyBatisDAO<AppInfoEO, Long> implements IUserAppDBDAO{

	@Override
	public List<AppInfoEO> selectAuthedApps(Long uid) {
		Map<String, Object> queryParam = new HashMap<String, Object>();
		queryParam.put("uid", uid);
		queryParam.put("isDeleted", false);
		List<AppInfoEO> authedApps = this.selectByStatement(".selectAuthedApps", queryParam, "name", true);
		return authedApps;
	}

	@Override
	public List<AppInfoEO> selectUnAuthedApps(Long uid) {
		Map<String, Object> queryParam = new HashMap<String, Object>();
		queryParam.put("uid", uid);
		queryParam.put("isDeleted", false);
		List<AppInfoEO> authedApps = this.selectByStatement(".selectUnAuthedApps", queryParam, "name", true);
		return authedApps;
	}

	@Override
	public void insert(Long uid, Long appId) {
		Map<String, Object> insertParam = new HashMap<String, Object>();
		insertParam.put("uid", uid);
		insertParam.put("appId", appId);
		this.getSqlSession().insert(this.getMapperNamespace() + ".insertUserApp", insertParam);
	}

	@Override
	public void deleteByUid(Long uid) {
		this.getSqlSession().delete(this.getMapperNamespace() + ".deleteByUid", uid);
	}
	
}
